package xyz.xmh.executor;

import xyz.xmh.dao.file.FileDao;
import xyz.xmh.dao.recycle.RecycleDao;
import xyz.xmh.pojo.entity.BaseItem;
import xyz.xmh.pojo.enums.CategoryEnum;
import xyz.xmh.pojo.enums.CheckNameEnum;
import xyz.xmh.pojo.request.file.ListRequest;
import xyz.xmh.pojo.request.file.MultiDownloadUrlRequest;
import xyz.xmh.pojo.request.file.SearchRequest;
import xyz.xmh.pojo.request.file.UpdateRequest;
import xyz.xmh.pojo.response.file.*;

import java.nio.file.OpenOption;
import java.nio.file.Path;

/**
 * 2021/10/26 14:30 星期二<br/>
 *
 * @author xuMingHai
 */
public class BaseExecutor implements Executor {

    private final FileDao fileDao;

    private final RecycleDao recycleDao;

    public BaseExecutor(FileDao fileDao, RecycleDao recycleDao) {
        this.fileDao = fileDao;
        this.recycleDao = recycleDao;
    }

    @Override
    public ListResponse list() {
        return fileDao.list();
    }

    @Override
    public ListResponse list(ListRequest listRequest) {
        return fileDao.list(listRequest);
    }

    @Override
    public SearchResponse search(String fileName) {
        return fileDao.search(fileName);
    }

    @Override
    public SearchResponse search(String fileName, CategoryEnum categoryEnum) {
        return fileDao.search(fileName, categoryEnum);
    }

    @Override
    public SearchResponse search(SearchRequest searchRequest) {
        return fileDao.search(searchRequest);
    }

    @Override
    public BaseItem get(String fileId) {
        return fileDao.get(fileId);
    }

    @Override
    public DownloadUrlResponse getDownloadUrl(String fileId) {
        return fileDao.getDownloadUrl(fileId);
    }

    @Override
    public long downloadFile(String fileId, Path path, OpenOption... openOptions) {
        return fileDao.downloadFile(fileId, path, openOptions);
    }

    @Override
    public MultiDownloadUrlResponse getMultiDownloadUrl(MultiDownloadUrlRequest multiDownloadUrlRequest) {
        return fileDao.getMultiDownloadUrl(multiDownloadUrlRequest);
    }

    @Override
    public long multiDownloadFile(MultiDownloadUrlRequest multiDownloadUrlRequest, Path path, OpenOption... openOptions) {
        return fileDao.multiDownloadFile(multiDownloadUrlRequest, path, openOptions);
    }

    @Override
    public CreateFolderResponse createFolder(String parentFileId, String name, CheckNameEnum checkNameEnum) {
        return fileDao.createFolder(parentFileId, name, checkNameEnum);
    }

    @Override
    public CreateFolderResponse createFolder(String parentFileId, String name) {
        return fileDao.createFolder(parentFileId, name);
    }

    @Override
    public CreateFolderResponse createFolder(String name) {
        return fileDao.createFolder(name);
    }

    @Override
    public CreateFileResponse uploadFile(String parentFileId, Path path, CheckNameEnum checkNameEnum) {
        return fileDao.uploadFile(parentFileId, path, checkNameEnum);
    }

    @Override
    public CreateFileResponse uploadFile(String parentFileId, Path path) {
        return fileDao.uploadFile(parentFileId, path);
    }

    @Override
    public CreateFileResponse uploadFile(Path path) {
        return fileDao.uploadFile(path);
    }

    @Override
    public boolean trash(String fileId) {
        return recycleDao.trash(fileId);
    }

    @Override
    public BaseItem update(UpdateRequest updateRequest) {
        return fileDao.update(updateRequest);
    }

    @Override
    public BaseItem update(String fileId, String name) {
        return fileDao.update(fileId, name);
    }
}
